package controllers

import (
	"my-gin-app/src/services"
	"net/http"

	"github.com/gin-gonic/gin"
)

func GeneratePDF(c *gin.Context) {
	var patient services.Patient
	if err := c.ShouldBindJSON(&patient); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	if err := services.GeneratePDF(patient); err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}

	c.File("patient_record.pdf")
}
